package de.sup.scs.prototyp.client.ui.title;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
import com.gwtplatform.mvp.client.proxy.PlaceManager;

public class TitleView extends ViewWithUiHandlers<TitleUiHandlers> implements TitlePresenter.MyView {

    @UiField
    LayoutPanel panel;

    @UiField
    Button buttonPD;

    @UiField
    Button buttonSD;

    @UiField
    Button buttonWD;

    @UiField
    Button buttonLanguage;

    public interface MyUiBinder extends UiBinder<Widget, TitleView> {}

    @Inject
    public TitleView(final MyUiBinder binder, PlaceManager placeManager){
        binder.createAndBindUi(this);
    }

    @UiHandler({"buttonPD", "buttonSD", "buttonWD"})
    public void handleClick(ClickEvent event) {

        if (event.getSource().equals(buttonPD)) {
            getUiHandlers().OnClick(0);
        } else if (event.getSource().equals(buttonSD)){
            getUiHandlers().OnClick(1);
        } else if (event.getSource().equals(buttonWD)){
            getUiHandlers().OnClick(2);
        }
    }

    @Override
    public Widget asWidget() {
        return panel;
    }
}
